package com.itheima.bigevents.pojo;

import java.io.Serializable;

public class ReqResult<T> implements Serializable {

    public static final String SUCCESS = "0000";

    public static final String ERR_SYS = "1000";

    public static final String ERR_BIZ = "2000";

    private String code = SUCCESS;
    private String displayCode;
    private String message;
    private T data = null;

    public ReqResult() {
    }

    public ReqResult(String code, String displayCode, String message) {
        this.code = code;
        this.displayCode = displayCode;
        this.message = message;
    }

    public ReqResult(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public ReqResult(String code, String message, T data) {
        this.code = code;
        this.displayCode = code;
        this.message = message;
        this.data = data;
    }

    public boolean isSuccess() {
        return "0000".equals(this.code);
    }

    public static <T> ReqResult<T> success() {
        return create("0000", "成功", null);
    }

    public static <T> ReqResult<T> success(T obj) {
        return create("0000", "成功", obj);
    }

    public static <T> ReqResult<T> success(String msg, T obj) {
        return create("0000", msg, obj);
    }

    public static <T> ReqResult<T> create(String code, String msg, T data) {
        return new ReqResult(code, msg, data);
    }

    public String getCode() {
        return this.code;
    }

    public String getDisplayCode() {
        return this.displayCode;
    }

    public String getMessage() {
        return this.message;
    }

    public T getData() {
        return this.data;
    }

    public ReqResult setCode(String code) {
        this.code = code;
        return this;
    }

    public void setDisplayCode(String displayCode) {
        this.displayCode = displayCode;
    }

    public ReqResult setMessage(String message) {
        this.message = message;
        return this;
    }

    public ReqResult setData(T data) {
        this.data = data;
        return this;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof ReqResult)) {
            return false;
        } else {
            ReqResult<?> other = (ReqResult) o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                label59:
                {
                    Object this$code = this.getCode();
                    Object other$code = other.getCode();
                    if (this$code == null) {
                        if (other$code == null) {
                            break label59;
                        }
                    } else if (this$code.equals(other$code)) {
                        break label59;
                    }

                    return false;
                }

                Object this$displayCode = this.getDisplayCode();
                Object other$displayCode = other.getDisplayCode();
                if (this$displayCode == null) {
                    if (other$displayCode != null) {
                        return false;
                    }
                } else if (!this$displayCode.equals(other$displayCode)) {
                    return false;
                }

                Object this$message = this.getMessage();
                Object other$message = other.getMessage();
                if (this$message == null) {
                    if (other$message != null) {
                        return false;
                    }
                } else if (!this$message.equals(other$message)) {
                    return false;
                }

                Object this$data = this.getData();
                Object other$data = other.getData();
                if (this$data == null) {
                    if (other$data != null) {
                        return false;
                    }
                } else if (!this$data.equals(other$data)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof ReqResult;
    }

    public int hashCode() {
        int result = 1;
        Object $code = this.getCode();
        result = result * 59 + ($code == null ? 43 : $code.hashCode());
        Object $displayCode = this.getDisplayCode();
        result = result * 59 + ($displayCode == null ? 43 : $displayCode.hashCode());
        Object $message = this.getMessage();
        result = result * 59 + ($message == null ? 43 : $message.hashCode());
        Object $data = this.getData();
        result = result * 59 + ($data == null ? 43 : $data.hashCode());
        return result;
    }

    public String toString() {
        return "RpcResult(code=" + this.getCode() + ", displayCode=" + this.getDisplayCode() + ", message=" + this.getMessage() + ", data=" + this.getData() + ")";
    }
}

